package com.handpay.nocardpay.baselibrary.main.all.presenter;

import android.content.Context;

import com.handpay.nocardpay.baselibrary.commbase.model.IBaseModel;
import com.handpay.nocardpay.baselibrary.commbase.model.bean.BaseErrorInfo;
import com.handpay.nocardpay.baselibrary.commbase.presenter.IBasePresenter;
import com.handpay.nocardpay.baselibrary.main.all.model.BannerByChannelModelImpl;
import com.handpay.nocardpay.baselibrary.main.all.model.bean.BannerByChannelBean;
import com.handpay.nocardpay.baselibrary.main.all.view.IAllView;

import java.util.HashMap;

/**
 * Created by lyang on 2018/2/2.
 */

public class BannerPresenterImpl implements IBasePresenter, IBaseModel.OnRequestFinishedListener<BannerByChannelBean> {

    private BannerByChannelModelImpl mBannerByChannelModelImpl;
    private IAllView mAllView;
    private Context mContext;
//    private LowestAccountTransferAmount mLowestAccountTransferAmount;


    public BannerPresenterImpl(IAllView allView, Context context) {
        this.mBannerByChannelModelImpl = new BannerByChannelModelImpl(context);
        this.mAllView = allView;
        mContext = context;
    }


    public void getBannerByChannel(HashMap<String, Object> paramers, Class<BannerByChannelBean> clzz, boolean isShowLoading) {
        if (mAllView != null) {
            if (isShowLoading) {
                mAllView.showProgress();
            }
        }
        mBannerByChannelModelImpl.getBannersByChannel(paramers, clzz, this);
    }

    @Override
    public void onDestory() {

    }

    @Override
    public void onError(BaseErrorInfo baseErrorInfo) {
        if (mAllView != null) {
            mAllView.hideProgress();
            mAllView.showErrorAlert(baseErrorInfo);
        }
    }

    @Override
    public void onSuccess(BannerByChannelBean response) {
        if (mAllView != null) {
            mAllView.hideProgress();
            mAllView.setBannerByChannel(response);
        }
    }
}